FROM ubuntu:22.04 AS build

# 安装构建依赖
RUN apt-get update && \
    apt-get install -y build-essential cmake git libjsoncpp-dev

# 克隆并构建 cpp-httplib
RUN git clone https://github.com/yhirose/cpp-httplib.git && \
    cd cpp-httplib && \
    mkdir build && cd build && \
    cmake .. && make && make install

# 设置工作目录
WORKDIR /app

# 复制源代码
COPY . .

# 创建构建目录并编译
RUN mkdir build && cd build && \
    cmake .. && make

# 运行时镜像
FROM ubuntu:22.04

# 安装运行时依赖
RUN apt-get update && apt-get install -y libjsoncpp-dev

# 复制可执行文件
COPY --from=build /app/build/bitmap_processor /usr/local/bin/

# 暴露端口
EXPOSE 8081

# 启动服务
CMD ["bitmap_processor"]